1 package uba.db.sql.language;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import junit.framework.TestCase;
7 import uba.db.testhelpers.TestUtils;
8
9 /***
10 * @version $Revision: 1.2 $
11 */
12 public class GreatherThanEqualsComparisonTest extends TestCase {
13 private GreatherThanEqualsComparison comp;
14 private GreatherThanEqualsComparison sameComp;
15 private GreatherThanEqualsComparison otherComp;
16
17 /***
18 * @see junit.framework.TestCase#setUp()
19 */
20 protected void setUp() throws Exception {
21 super.setUp();
22 comp = new GreatherThanEqualsComparison(new ColumnName("a"), new ColumnName("b"));
23 sameComp = new GreatherThanEqualsComparison(new ColumnName("a"), new ColumnName(
24 "b"));
25 otherComp = new GreatherThanEqualsComparison(new ColumnName("c"),
26 new IntegerValue(3));
27 }
28
29 /***
30 * Test de igualdad entre dos instancias.
31 */
32 public void testEquals() throws Exception {
33 TestUtils.assertEqualsImplementation(comp, sameComp, otherComp);
34 }
35
36 /***
37 * Test: obtener el resultado de una comparacion
38 */
39 public void testIsTrueWith() throws Exception {
40 Map values = new HashMap();
41 values.put(new ColumnName("a"), new Integer(10));
42 values.put(new ColumnName("b"), new Integer(20));
43 values.put(new ColumnName("c"), new Integer(3));
44
45 EvaluationContext context = new MockEvaluationContext(values);
46
47 assertFalse(comp.isTrueWith(context));
48 assertEquals(Boolean.FALSE, comp.valueWith(context));
49 assertTrue(otherComp.isTrueWith(context));
50 assertEquals(Boolean.TRUE, otherComp.valueWith(context));
51 }
52 }